(function(app){
	app
		.controller("content_10_checkCtrl",["$scope","$state","myFactory",'$http','$stateParams','$state',"$q",'$timeout','$location',function($scope,$state,myFactory,$http,$stateParams,$state,$q,$timeout,$location){

			//接收参数
			var chdrnum01 =  $stateParams.chdrnum01; //保单号
			var chdrcoy = $stateParams.chdrcoy; //保单公司号码
			var state = $stateParams.state;//获得跳转过来的路由
			var item10 = $stateParams.item10;
			var token=sessionStorage.getItem("token");
			//绑定到页面
			$scope.chdrnum01 = $stateParams.chdrnum01;
			$scope.showFlag = true; //控制前端是否显示“详情、重审、退出”三个功能
			$scope.item10 = $stateParams.item10;

			$scope.show10TbrFlag=false; //默认隐藏更改个人身份资料-投保人
			//$scope.reason = itemData.item10.reason;
			var clientCount=item10.clientCount;
			$scope.client_LF = item10.clientList[0];
			
			//日期显示方式处理 by zzq 2018-3-6
			$scope.client_LF.availDataClose = DateTools($scope.client_LF.availDataClose);
			//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
			$scope.client_LF.availDataStart = DateTools($scope.client_LF.availDataStart);
			//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
			$scope.client_LF.birthDay = DateTools($scope.client_LF.birthDay);			
			
			if(clientCount>1){
			    $scope.show10TbrFlag=true; //显示更改个人身份资料-投保人
			    $scope.client_OW = item10.clientList[1];
			    
			  //日期显示方式处理 by zzq 2018-3-6
				$scope.client_OW.availDataClose = DateTools($scope.client_OW.availDataClose);
				// 	S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
				$scope.client_OW.availDataStart = DateTools($scope.client_OW.availDataStart);
				// 	S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
				$scope.client_OW.birthDay = DateTools($scope.client_OW.birthDay);			
			}


			//根据路由判断是否要显示详情、重新受理、退出三个功能
			if("history_detail"==state){
				$scope.showFlag = false;//不显示
			}

			//重新受理
			$scope.renew = function(){
				myFactory.renew();
			}

			//退出移动保全
			$scope.exit = function(){
				myFactory.exit();
			}

			//返回函数
			$scope.goBack = function () {
				myFactory.goBack();
			}

			//转换日期方法  例如：20170225--->2017-02-25 by zzq 2018-3-6
			function DateTools(date){
				date = String(date) ;
				if($.trim(date)!=""){
					return date.replace(/^(\d{4})(\d{2})(\d{2})$/, "$1-$2-$3");
				}else{
					return date;
				}
			}
			
			//保单详情弹窗
			$scope.showPolicyDetail = function(){
				modal('open','policyModalOn10Check','policyWindowOn10Check','policyCloseXOn10Check');
				var timestamp=myFactory.getTimetamp();
				var sfis= "chdrnum-chdrcoy-token-timestamp";
				var signStr="chdrnum="+chdrnum01+"&chdrcoy="+chdrcoy+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				//初始化时候查询保单详情
				$http({
					method: 'GET',
					url: app.domain + 'query/restFindPolicyDetail.action',
					params: {'chdrnum': chdrnum01,'chdrcoy': chdrcoy,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						policyData = response.data.data;
						$scope.policyData = policyData;
					}
				}, function errorCallback(response) {
					$.alert({
						title: '',
						text: '初始化查询订单详情失败!',
						onOK: function () {
							//点击确认
						}
					});
				});
			}

			//保单详情弹窗关闭函数
			$scope.policyCancelOn10Check = function(){
				modal('close','policyModalOn10Check','policyWindowOn10Check','policyCloseXOn10Check');
			}
			//关闭遮罩
			$scope.overwindowClose = function(){
				//$(".overwindow").show();
				$(".overwindow").hide();
				$(".overmodal").hide();
			}


		}]);        
})(app)